package lion.lua;

import java.nio.ByteOrder;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import lion.netty4.filter.MessageFireWallProtoFilter;

public class LuaServerRawInitializer extends ChannelInitializer<SocketChannel> {

	@Override
	public void initChannel(SocketChannel ch) throws Exception {
		ChannelPipeline p = ch.pipeline();
		// p.addLast("readTimeoutHandler", new
		// ReadTimeoutHandler(900));//15分钟没收到断socket
		p.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 65546, 0, 2, 0, 2, true));
		p.addLast("frameEncoder", new LengthFieldPrepender(ByteOrder.LITTLE_ENDIAN, 2, 0, false));
		p.addLast("fireWallFilter", new MessageFireWallProtoFilter());
		p.addLast("handler", new LuaServerRawHanlder());
	}

}
